#pragma once

#include"HashTable.h"

namespace bit
{
	template<class K, class Hash = HashFunc<K>>
	class unordered_set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename Hash_bucket::HashTable<K, const K, SetKeyOfT, Hash>::iterator iterator;
		typedef typename Hash_bucket::HashTable<K,const K, SetKeyOfT, Hash>::const_iterator const_iterator;

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		const_iterator begin()const
		{
			return _ht.begin();
		}

		const_iterator end()const
		{
			return _ht.end();
		}

		pair<iterator, bool> insert(const K& key)
		{
			return _ht.Insert(key);
		}

		iterator find(const K& key)
		{
			return _ht.Find(key);
		}

		bool erase(const K& key)
		{
			return _ht.Erase(key);
		}
	private:
		Hash_bucket::HashTable<K, const K, SetKeyOfT, Hash> _ht;
	
	};

	void Func(const unordered_set<int>& s)
	{
		unordered_set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}

	void test_unordered_set1()
	{
		unordered_set<int> ht;
		ht.insert(3);
		ht.insert(33);
		ht.insert(45);
		ht.insert(4);
		ht.insert(52);
		ht.insert(77);

		unordered_set<int>::iterator it = ht.begin();
		while (it != ht.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;

		for (auto e : ht)
		{
			cout << e << " ";
		}
		cout << endl;
	}
}

